<?php

$GLOBALS['Md'] = "RHUSJW24";
$GLOBALS['Pd'] = "B";

require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
require_once($GLOBALS['PAD']."Modules/RHUSJW24/modconf.mex"); 

	if(!isset($_POST['it_Status'])){$_POST['it_Status']='Aberto';}

	
	
MYTCONN();
		$GET = $GLOBALS['MYT']->db_array("SELECT
				ref AS ref,
				main_users_ref AS user,
				main_office_ref AS balcao,
				data AS data,
				estado AS estado,
				problema AS problema,
				prioridade AS prioridade,
				Data_Reso as data_reso,
				smb_Name as atribuido_a,
				obs as obs
				FROM systemoffice.it_requests
					LEFT OUTER JOIN systemoffice.staff_members ON smb_ID = atribuido_a
					WHERE estado = '{$_POST['it_Status']}'");
				
	$CARD = $GET[0];
			
?>
	

<div id="User_List"></div>


<script charset="utf-8" type="text/javascript">
 var  windowHeight = document.documentElement.clientHeight-180;

Ext.onReady(function(){

    var myData = [
	<?php   
	
	for ($i=1;$i<=$CARD;$i++) {
	echo "[{$i},'{$GET[$i]['ref']}','{$GET[$i]['user']}','{$GET[$i]['balcao']}','{$GET[$i]['data']}','{$GET[$i]['estado']}','".trimall($GET[$i]['problema'])."','{$GET[$i]['prioridade']}','{$GET[$i]['data_reso']}','{$GET[$i]['atribuido_a']}','".trimall($GET[$i]['obs'])."']";
		if ($i<$CARD) {
			echo ',';
		}
    } ?>
    ];

    var ds = new Ext.data.Store({
        reader: new Ext.data.ArrayReader({}, [
               {name: 'id'},
			   {name: 'ref', type: 'int'},
               {name: 'user', type: 'string'},
               {name: 'balcao', type: 'string'},
               {name: 'data', type: 'string'},
			   {name: 'estado', type: 'string'},
               {name: 'problema', type: 'string'},
               {name: 'prioridade', type: 'string'},
			   {name: 'data_reso', type: 'string'},
               {name: 'atribuido_a', type: 'string'},
			   {name: 'obs', type: 'string'}
          ])
    });
    ds.loadData(myData);
    var colModel = new Ext.grid.ColumnModel([
        {header: "Ref", width: 60, sortable: true, locked:true, dataIndex: 'ref'},
        {header: "User", width: 80, sortable: true, locked:true, dataIndex: 'user'},
        {header: "Balcao", width: 150, sortable: true, dataIndex: 'balcao'},
        {header: "Data", width: 150, sortable: true, locked:true,dataIndex: 'data'},
        {header: "Estado", width: 70, sortable: true, locked:true,dataIndex: 'estado'},
        {header: "Problema", width: 160, sortable: true, locked:true,dataIndex: 'problema'},
        {header: "Prioridade", width: 80, sortable: true, locked:true,dataIndex: 'prioridade'},
	    {header: "Data Resolução", width: 120, sortable: true, locked:true,dataIndex: 'data_reso'},
        {header: "Atribuido a", width: 110, sortable: true, locked:true,dataIndex: 'atribuido_a'},
		{header: "Obs", width: 120, sortable: true, locked:true,dataIndex: 'obs'}
    ]);

   var selmode = new Ext.grid.RowSelectionModel({});
   
   
   var Console = new Ext.grid.GridPanel({
	            ds: ds,
	            cm: colModel,
	            sm: selmode,
				listeners: {
	 				rowdblclick: function(ds, row) { 
					var record = ds.getStore().getAt(row);
  					var value = record.get('ref');	
					idwindow('Propriedades do Pedido','user_properties','user_form','modules/It_Reports/change_problem_status.php?RSID='+value,750,480);
					 }
				},
	    height:  windowHeight ,
        renderTo: 'User_List'
    });
		
});
</script>